﻿<!DOCTYPE html>
<html>
<head>
	<script src="//code.jquery.com/jquery-3.7.1.js" type="text/javascript"></script>
	<script src="../../jsrender.js" type="text/javascript"></script>
	<link href="../resources/demos.css" rel="stylesheet" type="text/css" />

	<link href="../resources/movielist.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a href="../demos.html">JsRender Demos</a><br />

<h3>Using {{if}} and {{else}} to render conditional sections.</h3>

<script id="movieTemplate" type="text/x-jsrender">
	<tr>
		<td>{{>title}}</td>
		<td>
			{{if languages}}
				Alternative languages: <em>{{>languages}}</em>.
			{{else subtitles}}
				Original language only... <br/>subtitles in <em>{{>subtitles}}</em>.
			{{else}}
				Original version only, without subtitles.
			{{/if}}
		</td>
	</tr>
</script>

<table>
	<thead><tr><th>title</th><th>languages</th></tr></thead>
	<tbody id="movieList"></tbody>
</table>

<script type="text/javascript">

	var movies = [
		{
			title: "Meet Joe Black",
			languages: "English and French",
			subtitles: "English"
		},
		{
			title: "Eyes Wide Shut",
			subtitles: "French and Spanish"
		},
		{
			title: "The Mighty"
		},
		{
			title: "City Hunter",
			languages: "Mandarin and Chinese"
		}
	];

	$( "#movieList" ).html(
		$( "#movieTemplate" ).render( movies )
	);

</script>

</body>
</html>
